草庐IT

spring boot自动装配之@ComponentScan详解

全部标签

java - 自动更新 Action 的 isEnabled()

我已经编写了一个SwingGUI,其中包含多个与同一Action子类关联的控件。Action子类的实现遵循以下伪代码:publicclassMyGUI{Gizmogizmo_;//DefinedelsewherepublicclassAction_StartPlaybackextendsAbstractAction{/*ctor*/publicAction_StartPlayback(Stringtext,ImageIconicon,Stringdesc,Integermnem){super(text,icon);putValue(SHORT_DESCRIPTION,desc);put

Java:收据打印机自动切割

我正在使用JavaPrintServiceAPI打印到收据打印机。打印很好,但完成后不会自动剪切。如何让打印机自动切纸?这是我用来打印的代码:StringdefaultPrinter=PrintServiceLookup.lookupDefaultPrintService().getName();System.out.println("Defaultprinter:"+defaultPrinter);PrintServiceservice=PrintServiceLookup.lookupDefaultPrintService();InputStreamis=null;try{prin

java - Hibernate,自动持久化依赖对象

我是Hibernate的新手,一直在尝试确定它能为您做什么以及它需要您做什么。一个大的对象正在处理一个对象,该对象具有数据库中尚不存在的依赖项。例如,我有一个Project对象,其中包含接受Manufacturer对象作为其值的Manufacturer字段。在数据库中,我有一个带有mfr_id列的产品表,该列是对制造商表的引用(一种相当典型的单向一对多关系)。如果分配给产品对象的制造商与数据库中已有的制造商相关,则没有问题。但是,当我尝试保存或更新引用尚未保留的制造商的对象时,操作失败并出现异常。Exceptioninthread"Application"org.hibernate.T

java - 将Jsch放入连接池详解

我将Jsch放入commons-pool(带有springpool支持)并取得初步成功http://docs.spring.io/spring/docs/3.2.4.RELEASE/spring-framework-reference/htmlsingle/#aop-ts-pool但是:我们应该在session中合并channel而不是合并session吗?每个Jschsession创建一个线程。合并Jschsession将创建x个线程。Poolingchannels,真的只有一个Jsch线程。(commons-pool)如果Jschsession过时会发生什么?如何在commons-

java - Spring 4 中有多个@ComponentScan?

我正在使用带有Java注释的Spring4.16,我想做类似的事情:@Configuration@ComponentScan(basePackages="com.example.business",includeFilters=@ComponentScan.Filter(type=FilterType.ASSIGNABLE_TYPE,value=ServiceComponent.class))@ComponentScan(basePackages="com.example.business.framework")publicclassServicesBaseConfiguration{

无法解析 Java 9 自动模块依赖项/找不到模块

我正在尝试将一些遗留应用程序迁移到新的Java9模块系统,以加强其封装。我从外到内开始,假设外围的类具有最少的外部依赖性。如您所料,我已经声明了一个非常开放的模块:modulecom.example.user{exportscom.example.user;}这会立即破坏整个项目(在所有类中),突然间,外部依赖项的每个导入都不再解析(导致超过1kJava问题):Theimportcom.otherexamplecannotberesolvedTheimportorg.springframeworkcannotberesolvedetc.同一项目中的本地包com.example.pric

java - 如何在 HttpClient 中自动重定向(java,apache)

我创建httpClient并设置设置HttpClientclient=newHttpClient();client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);client.getParams().setContentCharset("UTF-8");第一次请求(获取)GetMethodfirst=newGetMethod("http://vk.com");intreturnCode=client.executeMethod(first);BufferedReaderbr=null;Stringline

java - 如何在不知道密码的情况下使用 Spring Security 以用户身份自动登录?

我的应用程序使用SpringSecurity,我的客户要求:用户在注册后能够自动登录。管理员可以在不知道密码的情况下以任何用户身份登录。所以我需要弄清楚如何在不知道密码的情况下以任何用户身份自动登录。如何使用SpringSecurity实现这一点? 最佳答案 为了让它工作,我必须:配置对UserDetailsS​​ervice(jdbcUserService)的引用在我的Controller中Autowiring我的userDetailsManager:@Autowired@Qualifier("jdbcUserService")/

java - SpringBoot 2.1.x中使用RestTemplateBuilder的requestFactory自定义RestTemplate不向下兼容1.5.x版本

在SpringBoot1.5.x中,我创建了一个自定义RestTemplate,如下所示:@BeanpublicRestTemplaterestTemplate(RestTemplateBuilderrestTemplateBuilder){PoolingHttpClientConnectionManagerpoolingConnectionManager=newPoolingHttpClientConnectionManager();poolingConnectionManager.setMaxTotal(restTemplateProps.getMaxConnectionsPerP

java - 我应该如何将 JpaRepository.findOne() 与 SpringBoot 一起使用?

我刚开始通过阅读SpringBootinAction这本书来学习SpringBoot,我正在学习这本书的示例,尝试自己运行它们,但我有一个使用JpaRepository.findOne()时出现问题。我已经遍历了整章来寻找我可能的不匹配之处。但是,它就是行不通。该项目应该是一个简单的阅读列表。代码如下:读者@Entity:packagecom.lixin.readinglist;importorg.springframework.data.annotation.Id;importorg.springframework.security.core.GrantedAuthority;imp